package org.osiris.client.utils;


import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;

/**
 * {@link AsyncCallback} switch recognises {@link ServiceSecurityException} and
 * handles it gracefully.
 * 
 * @author See Wah Cheng
 * @created 5 Jun 2009
 */
public abstract class AutoErrorHandlingAsyncCallback<T> implements AsyncCallback<T> {

	final public void onFailure(Throwable throwable) {
		if (throwable instanceof ServiceSecurityException) {
			Window.alert("You do not have enough privilege to carry out the operation!");
		} else {
			Window.alert(throwable.getMessage());
		}
	}
}